<%--
  Created by IntelliJ IDEA.
  User: Gaara_XHG
  Date: 2020/10/7
  Time: 23:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<%--<link rel="stylesheet" type="text/css" href="/prj/plugins/layui/css/layui.css">--%>
<c:if test="${insertStatus==1}">
    <span>插入成功,插入车辆id为：<span style="color: red">${carID}</span></span>
</c:if>
<c:if test="${remind==1}">
    <span style="color: red;font-weight: bold">该车辆已经入库，不可重复操作！</span>
</c:if>
<div style="border:1px solid #999; padding: 10px">
    <form role="form" id="adCa">
        <div class="col-md-4 col-md-offset-2 form-group" style="color: grey;font-weight: normal">
            <label for="brId" class="control-label">车品牌&nbsp;:&nbsp;</label><input type="text" name="brId"  id="brId" placeholder="请输入品牌">
        </div>
        <div class="col-md-6 form-group">
            <label for="stId" class="control-label">车系&nbsp;:&nbsp;</label><input type="text"  name="stId" id="stId" placeholder="请输入车系">
        </div>
<%--        <div class="col-md-4 form-group">--%>
<%--            <label for="cPhoto" class="control-label">汽车封面&nbsp;:&nbsp;</label><input type="text" name="cPhoto" id="cPhoto" placeholder="请输入汽车封面">--%>
<%--        </div>--%>
            <br>
            <br>
        <div class="col-md-4 form-group">
            <label for="cPrice" class="control-label">底价&nbsp;:&nbsp;</label><input type="text"  name="cPrice" id="cPrice" placeholder="请输入底价">
        </div>
        <div class="col-md-4 form-group">
            <label for="cOprice" class="control-label">售价&nbsp;:&nbsp;</label><input type="text" name="cOprice" id="cOprice" placeholder="请输入售价">
        </div>
        <div class="col-md-4 form-group">
            <label for="cDrive" class="control-label">驱动&nbsp;:&nbsp;</label><input type="text"  name="cDrive" id="cDrive" placeholder="请输入驱动类型">
        </div>
            <br>
            <br>
        <div class="col-md-4 form-group">
            <label for="cAge" class="control-label">车龄&nbsp;:&nbsp;</label><input type="text"  name="cAge" id="cAge" placeholder="请输入车龄">
        </div>
        <div class="col-md-4 form-group">
            <label for="cSeat" class="control-label">座位&nbsp;:&nbsp;</label><input type="text" name="cSeat" id="cSeat" placeholder="请输入座位">
        </div>
        <div class="col-md-4 form-group">
            <label for="cMileage" class="control-label">里程&nbsp;:&nbsp;</label><input type="text" name="cMileage"  id="cMileage" placeholder="请输入里程">
        </div>
            <br>
            <br>
        <div class="col-md-4 form-group">
            <label for="cPaifang" class="control-label">排放&nbsp;:&nbsp;</label><input type="text" name="cPaifang" id="cPaifang" placeholder="车牌排放标准（国一至国六）">
        </div>
        <div class="col-md-4 form-group">
            <label for="carCarnumber" class="control-label">车牌号&nbsp;:&nbsp;</label><input type="text" name="carCarnumber" id="carCarnumber" placeholder="请输入车牌号">
        </div>
        <div class="col-md-4 form-group">
            <label for="salId" class="control-label">销售人员&nbsp;:&nbsp;</label><input type="text" name="salId" id="salId" placeholder="请输入销售人员id">
        </div>
            <br>
            <br>
        <div class="col-md-4 form-group">
            <label for="cCus" class="control-label">油耗&nbsp;:&nbsp;</label><input type="text" name="cCus" id="cCus" placeholder="请输入油耗">
        </div>
        <div class="col-md-4 form-group">
            <label for="cUse" class="control-label">用途&nbsp;:&nbsp;</label><input type="text" name="cUse" id="cUse" placeholder="请输入用途">
        </div>
        <div class="col-md-4 form-group">
            <label for="cGear" class="control-label">档位&nbsp;:&nbsp;</label><input type="text" name="cGear" id="cGear" placeholder="请输入档位">
        </div>
            <br>
            <br>

        <div class="col-md-4 form-group">
            <label for="cRegistration" class="control-label">上牌时间&nbsp;:&nbsp;</label>
            <div class="input-append date form_datetime">
                <input size="20" type="text" value="2020-01-01" id="cRegistration" name="cRegistration" readonly>
                <span class="add-on"><i class="icon-remove"></i></span>
                <span class="add-on"><i class="icon-calendar"></i></span>
            </div>


        </div>
        <div class="col-md-4 form-group">
            <label for="cCreatedate" class="control-label">创建时间&nbsp;:&nbsp;</label>
            <div class="input-append date form_datetime">
                <input size="20" type="text" value="2020-01-01" id="cCreatedate"  name="cCreatedate" readonly>
                <span class="add-on"><i class="icon-remove"></i></span>
                <span class="add-on"><i class="icon-calendar"></i></span>
            </div>
        </div>
        <div class="col-md-4 form-group">
            <label for="cInsure" class="control-label">保险时间&nbsp;:&nbsp;</label>
            <div class="input-append date form_datetime" >
                <input size="20" type="text" value="2020-01-01"  name="cInsure" id="cInsure" readonly>
                <span class="add-on"><i class="icon-remove"></i></span>
                <span class="add-on"><i class="icon-calendar"></i></span>
            </div>
        </div>
            <br>
            <br>
            <br>
        <div class="col-md-4 form-group">
            <label for="cDesc" class="control-label">车辆基本描述</label>
            <textarea class="form-control" rows="4" id="cDesc" name="cDesc"></textarea>
        </div>
        <div class="col-md-4 form-group">
            <label for="cCheak" class="control-label">检测描述</label>
            <textarea class="form-control" rows="4" id="cCheak" name="cCheak"></textarea>
        </div>


<%--        <div class="col-md-4 form-group">--%>
<%--            <label type="hidden" for="inputPhoto">选择车辆照片上传</label>--%>
<%--            <input type="file" id="inputPhoto">--%>

<%--        </div>--%>
<%--        <div class="form-group">--%>
<%--            <label for="inputfile">文件输入</label>--%>
<%--            <input type="file" id="inputfile">--%>

<%--        </div>--%>

        <div class="col-md-4" style="height: 134px;padding-top: 40px"><span style="font-weight:bold;color: red;">请在提交车辆信息后添加车辆对应的图片(车辆封面及其其他展示图片)</span></div>

        <button type="button" id="ADD" class="btn btn-default">提交</button>
        <c:if test="${insertStatus==1}">
            <span>插入成功,插入车辆id为：<span style="color: red">${carID}</span></span>
        </c:if>
        <c:if test="${remind==1}">
            <span style="color: red;font-weight: bold">该车辆已经入库，不可重复操作！</span>
        </c:if>

        <c:if test="${insertStatus==1}">
            <div class="col-md-4 form-group">
                <a type="button" id="carmain">去上传车辆封面</a>
            </div>

            <div class="col-md-4 form-group">
                <a type="button" id="carmany">去上传车辆介绍图片</a>
            </div>

            <script>
                $("#carmain").click(function () {
                    window.location="/prj/AdminJsp/toNewCarMain/"+${carID}
                })
                $("#carmany").click(function () {
                    window.location="/prj/AdminJsp/toNewCarDesc/"+${carID}
                })
            </script>
        </c:if>


    </form>
</div>

<script>

    $(function () {

        $("#ADD").click(function () {
            // 取出所有数据
            let car = $("#adCa").serializeArray();
            let data = {};
            $.each(car, function (index, item) {
                data[item.name] = item.value;
            });
            let json = JSON.stringify(data);
            console.log("json:",json);

            $.ajax({
                type:'post',
                contentType : "application/json;charset=utf-8",
                url:'/prj/admin/addCar',
                data:JSON.stringify(data),
                success:function () {
                    $("#addCar").load("/prj/AdminJsp/toAddCar");
                }
            });

        });
    })
</script>

<script>
    $(function(){
        $(".form_datetime").datetimepicker({
            format: 'yyyy-mm-dd',
            todayBtn:true,
            maxView: 'year',
            minView: 'month'
        });
    })
</script>
